import { defineStore } from "pinia";
import { getItem, setItem } from "@/utils/localStorage";
const key = "config";

export const useConfigStore = defineStore(key, {
  state: () => {
    return {
      value: getItem(key) || {
        privateKey: null,
        privateKey: null,
        collectAddress: null,
        contractAddress: null,
        contractSymbol: null,
        token:null,
        poolType: "bsc",
        targetPrice: 1,
        gas: 0.00015,
        mode: "pump",
        buyMethod: "amount",
        buyIntervalMin:5,
        buyIntervalMax:10,
        sellIntervalMin:10,
        sellIntervalMax:20,
        buyMin: 0.00012,
        buyMax: 0.00018,
        sellMin: 0.00012,
        buyMax: 0.00018,
        intervalTime: 5,
        slippage: 0.5,
        enableConcurrent: false,
      },
    };
  },
  actions: {
    update(config) {
      this.value = config;
    },
    set(property, value) {
      this.value[property] = value;
    },
    get(property, defalut) {
      if (this.value[property]) {
        return this.value[property];
      } else {
        return defalut;
      }
    },
  },
});
